package com.lvhr.example.consumer;

import com.lvhr.rpc.config.RpcConfig;
import com.lvhr.rpc.constant.RpcConstant;
import com.lvhr.rpc.utils.ConfigUtils;
import java.util.Collections;

/**
 * 全局加载简易消费者示例
 */
public class ConsumerExample {
    public static void main(String[] args) {
        //默认系统自动加载
//        RpcConfig rpcConfigDefault = ConfigUtils.loadConfig(RpcConfig.class,"rpc");
        //默认环境加载
        RpcConfig rpcConfig = ConfigUtils.loadConfig(RpcConfig.class,"rpc","",null);
        //加载prod环境下：yml > yaml > properties
        RpcConfig rpcConfigYmlProd = ConfigUtils.loadConfig(RpcConfig.class,"rpc","prod",null);
        //优先加载Properties : yml > yaml > properties
        RpcConfig rpcConfigList = ConfigUtils.loadConfig(RpcConfig.class,"rpc","", RpcConstant.DEFAULT_CONFIG_ORDER);
        //只加载yaml文件
        RpcConfig rpcConfigOnlyYml = ConfigUtils.loadConfig(RpcConfig.class, "rpc", "", Collections.singletonList("yaml"));
        //只加载prod.Properties
        RpcConfig rpcConfigPropProd = ConfigUtils.loadConfig(RpcConfig.class, "rpc", "prod", Collections.singletonList("properties"));
        RpcConfig rpcConfigProp = ConfigUtils.loadConfig(RpcConfig.class, "rpc", "", Collections.singletonList("properties"));

//        System.out.println("这是系统默认自动加载 : " + "'" +rpcConfigDefault + "'");
        //application.yml
        System.out.println("这是默认环境加载 : " + "'" + rpcConfig + "'");
        //application-prod.yml
        System.out.println("这是多个prod环境下的默认优先级加载 :" + "'" + rpcConfigYmlProd + "'" );
        //application.yml
        System.out.println("这是存在多个环境下的《自定义》优先级yml加载 : " + "'" +  rpcConfigList + "'");
        //application.yaml
        System.out.println("这是指定加载yaml : " + "'" +  rpcConfigOnlyYml + "'");
        //properties-prod.properties
        System.out.println("这是存在多个prod环境下，只加载properties ： " + rpcConfigPropProd);
        //properties.properties
        System.out.println("这是默认环境下，只加载properties ： " + rpcConfigProp);
    }
}
